package de.upb.messerschmidt.set.entity;

import java.util.ArrayList;

import javax.jdo.annotations.Element;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

/**
 * Location stores some geographical data like the country of the Location
 * itself. Furthermore a list of {@link Room}s and {@link Event}s gets stored.
 * Rooms are strongly related to the Location (parent-relationship).
 * 
 * @author Tim Messerschmidt
 * 
 */

@PersistenceCapable
public class Location {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;
	@Persistent
	private String country;
	@Persistent
	private String city;
	@Persistent
	private String zip;
	@Persistent
	private String streetNr;
	@Persistent
	private String name;
	@Persistent(mappedBy = "location")
	@Element(dependent = "true")
	private ArrayList<Room> rooms = new ArrayList<Room>();
	@Persistent(mappedBy = "location")
	@Element(dependent = "true")
	private ArrayList<String> events = new ArrayList<String>();

	/**
	 * @param country
	 * @param city
	 * @param zip
	 * @param street
	 * @param nr
	 * @param name
	 * @param rooms
	 */
	public Location(String country, String city, String zip, String streetNr,
			String name) {
		this.country = country;
		this.city = city;
		this.zip = zip;
		this.streetNr = streetNr;
		this.name = name;
	}

	/**
	 * @return the key
	 */
	public Key getKey() {
		return key;
	}

	/**
	 * @return the country
	 */
	public String getCountry() {
		return country;
	}

	/**
	 * @return the city
	 */
	public String getCity() {
		return city;
	}

	/**
	 * @return the zip
	 */
	public String getZip() {
		return zip;
	}

	/**
	 * @return the streetNr
	 */
	public String getStreetNr() {
		return streetNr;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @return the rooms
	 */
	public ArrayList<Room> getRooms() {
		return rooms;
	}

	/**
	 * @return the events
	 */
	public ArrayList<String> getEvents() {
		return events;
	}

	/**
	 * @param key
	 *            the key to set
	 */
	public void setKey(Key key) {
		this.key = key;
	}

	/**
	 * @param country
	 *            the country to set
	 */
	public void setCountry(String country) {
		this.country = country;
	}

	/**
	 * @param city
	 *            the city to set
	 */
	public void setCity(String city) {
		this.city = city;
	}

	/**
	 * @param zip
	 *            the zip to set
	 */
	public void setZip(String zip) {
		this.zip = zip;
	}

	/**
	 * @param streetNr
	 *            the streetNr to set
	 */
	public void setStreetNr(String streetNr) {
		this.streetNr = streetNr;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @param rooms
	 *            the rooms to set
	 */
	public void setRooms(ArrayList<Room> rooms) {
		this.rooms = rooms;
	}

	/**
	 * @param events
	 *            the events to set
	 */
	public void setEvents(ArrayList<String> events) {
		this.events = events;
	}
}
